// pages/video/video.js
import request from '../../static/utils/request'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    videoGroupList: [], // 视频标签列表
    activeNav: '', // 导航标志
    navItemList: [], // 视频数据列表
    videoId: '', //视频标志
    videoUpdateTime: [], //存放视频播放的记录 key 视频id,value 播放时长
    isTriggered: true
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    // this.getVideoGroupList();
  },

  // 跳转到搜索页面
  toSearch() {
    wx.navigateTo({
      url: '/pages/search/search'
    });
  },


  // 页面展示出来时就会被加载一次
  onShow: function() {
    this.getVideoGroupList();
  },
  // 获取视频标签列表
  async getVideoGroupList() {
    let videoGroupListData = await request('/video/group/list');
    console.log(videoGroupListData);
    this.setData({
      videoGroupList: videoGroupListData.data.slice(0, 14),
      activeNav: videoGroupListData.data[0].id
    }, () => {
      this.getNavItemList(this.data.activeNav)
    })

    // setData 可用回调函数 来进行数据更改之后的处理
  },

  //获取标签下对应的视频数据
  async getNavItemList(id) {
    let navItemListData = await request('/video/group', {
      id
    });
    // 数据加载完毕
    wx.hideLoading();

    console.log(navItemListData)
      // 为了设置唯一标识，wx:key
    let index = 0;
    let videoList = navItemListData.datas.map(item => {
      item.id = index++;
      return item
    })
    this.setData({
      navItemList: videoList,
      isTriggered: false
    })
  },
  //点击事件
  handelActive(event) {
    let navIndex = event.currentTarget.dataset.id;
    this.setData({
      activeNav: navIndex >>> 0,
      navItemList: [] // 为了在跳转页面的时候，本页面是空白的
    });
    // >>>位移运算符 向右移0位强制将字符类型转换成数字类型

    // 添加加载动画
    wx.showLoading({
      title: "数据加载中"
    });


    // 调用函数 向服务器请求视频数据
    this.getNavItemList(navIndex >>> 0);
  },
  // 视频播放暂停
  handlePlay(event) {
    // 在播放新的视频之前关闭上一个正在播放的视频
    /*
    关键点：如何找到上一个视频的实例对象
    如何确认点击播放的视频和正在播放的视频不是同一个视频
    */

    let vid = event.currentTarget.id;
    // 关闭上一个播放的视频
    // this.vid != vid && this.videoContext && this.videoContext.stop();
    // this.vid = vid;
    this.setData({
        videoId: vid
      })
      // 创建当前控制video标签的实例对象
      // 这个api对安卓手机没有什么作用
    this.videoContext = wx.createVideoContext(vid)
    this.videoContext.play();
  },
  // 下拉刷新视频数据(自定义上拉触底回调)
  refreshVideoData(event) {
    console.log("下拉刷新");
    this.getNavItemList(event.currentTarget.id);
  },

  // 自定义上拉触底回调（加载更多）
  handleToLower(event) {
    // 数据分页 后端分页 前端分页
    console.log("触底回调");
    console.log("发送请求，在前端截取最新的数据，追加到视频列表的后方");
    console.log("网易云暂时没有提供分页的api");
    // 模拟数据
    let newVideoList = [{
        "type": 1,
        "displayed": false,
        "alg": "onlineHotGroup",
        "extAlg": null,
        "data": {
          "alg": "onlineHotGroup",
          "scm": "1.music-video-timeline.video_timeline.video.181017.-295043608",
          "threadId": "R_VI_62_8DA3CD20C1463D1FD4AA66162D71447C",
          "coverUrl": "https://p1.music.126.net/qAO0BZ5XKxzzTr-w4NpsLg==/109951165231321202.jpg",
          "height": 720,
          "width": 1280,
          "title": "左手指月 黄霄云",
          "description": null,
          "commentCount": 56,
          "shareCount": 186,
          "resolutions": [{
              "resolution": 240,
              "size": 14905458
            },
            {
              "resolution": 480,
              "size": 25140710
            },
            {
              "resolution": 720,
              "size": 35188779
            }
          ],
          "creator": {
            "defaultAvatar": false,
            "province": 370000,
            "authStatus": 0,
            "followed": false,
            "avatarUrl": "http://p1.music.126.net/jTMtszSmV5WwqcBJL5-nXw==/109951165785996058.jpg",
            "accountStatus": 0,
            "gender": 1,
            "city": 371100,
            "birthday": 942336000000,
            "userId": 625751921,
            "userType": 0,
            "nickname": "晚风予思念",
            "signature": "从一而终",
            "description": "",
            "detailDescription": "",
            "avatarImgId": 109951165785996060,
            "backgroundImgId": 109951164370007230,
            "backgroundUrl": "http://p1.music.126.net/ngfnN_eK-b4Sw4dIKx7iDw==/109951164370007233.jpg",
            "authority": 0,
            "mutual": false,
            "expertTags": null,
            "experts": null,
            "djStatus": 10,
            "vipType": 0,
            "remarkName": null,
            "backgroundImgIdStr": "109951164370007233",
            "avatarImgIdStr": "109951165785996058"
          },
          "urlInfo": {
            "id": "8DA3CD20C1463D1FD4AA66162D71447C",
            "url": "http://vodkgeyttp9.vod.126.net/cloudmusic/ZvCddCai_3087799075_shd.mp4?ts=1627721809&rid=075C5AA92CF77F4909672E580C65832E&rl=3&rs=bCBGyqNWzsryDjKVzygXbuZmgAYXlbaV&sign=33ee5532bffe27acfa5cef4420576e9d&ext=bIfTBSN7onNsmhQlQfxjtzl0Ri8qU6ztTZ3fceDkM4SzFwl7%2BhDApQHnJgMXGvCCO1e2hOj%2BxGHdAnddzunovAfSror7aX2SXFqkX04hCSkUEsYDIc%2BanHPz73N7UxbQ7VsJVVZkga1C2ALJTY%2B1ajeSUEpUPxXG%2BRN3eKjmZVRvNFOdzkdwn8V4HnzYTw68C%2FYdDtqC12KzLkUhbSxYdQdvQ68oiUU5wlW6PEUngO8yh8pq%2Fu0Urj5f4IIpy2nU",
            "size": 35188779,
            "validityTime": 1200,
            "needPay": false,
            "payInfo": null,
            "r": 720
          },
          "videoGroup": [{
              "id": 58100,
              "name": "现场",
              "alg": null
            },
            {
              "id": 59101,
              "name": "华语现场",
              "alg": null
            },
            {
              "id": 57108,
              "name": "流行现场",
              "alg": null
            },
            {
              "id": 59108,
              "name": "巡演现场",
              "alg": null
            },
            {
              "id": 1100,
              "name": "音乐现场",
              "alg": null
            },
            {
              "id": 5100,
              "name": "音乐",
              "alg": null
            }
          ],
          "previewUrl": null,
          "previewDurationms": 0,
          "hasRelatedGameAd": false,
          "markTypes": null,
          "relateSong": [],
          "relatedInfo": null,
          "videoUserLiveInfo": null,
          "vid": "8DA3CD20C1463D1FD4AA66162D71447C",
          "durationms": 139000,
          "playTime": 140379,
          "praisedCount": 1611,
          "praised": false,
          "subscribed": false
        }
      },
      {
        "type": 1,
        "displayed": false,
        "alg": "onlineHotGroup",
        "extAlg": null,
        "data": {
          "alg": "onlineHotGroup",
          "scm": "1.music-video-timeline.video_timeline.video.181017.-295043608",
          "threadId": "R_VI_62_6A2C396ECE05D4EE713344B7BF240786",
          "coverUrl": "https://p1.music.126.net/6NbJo7cVHo0dosH_Gf2XFw==/109951164095988109.jpg",
          "height": 720,
          "width": 1280,
          "title": "日本宅男的应援太震撼了！萧亚轩看完表示很尴尬",
          "description": "1.极乐净土\n2.再见的意义",
          "commentCount": 317,
          "shareCount": 141,
          "resolutions": [{
              "resolution": 240,
              "size": 51725043
            },
            {
              "resolution": 480,
              "size": 67317233
            },
            {
              "resolution": 720,
              "size": 108625445
            }
          ],
          "creator": {
            "defaultAvatar": false,
            "province": 430000,
            "authStatus": 0,
            "followed": false,
            "avatarUrl": "http://p1.music.126.net/J4LKZZYxokj2CRXzTDbhuQ==/109951164981540458.jpg",
            "accountStatus": 0,
            "gender": 0,
            "city": 430100,
            "birthday": -2209017600000,
            "userId": 1566621807,
            "userType": 204,
            "nickname": "汤姆音乐耶",
            "signature": "分享好听的音乐，感受别样的人生",
            "description": "",
            "detailDescription": "",
            "avatarImgId": 109951164981540460,
            "backgroundImgId": 109951162868126480,
            "backgroundUrl": "http://p1.music.126.net/_f8R60U9mZ42sSNvdPn2sQ==/109951162868126486.jpg",
            "authority": 0,
            "mutual": false,
            "expertTags": null,
            "experts": {
              "1": "音乐视频达人"
            },
            "djStatus": 0,
            "vipType": 0,
            "remarkName": null,
            "backgroundImgIdStr": "109951162868126486",
            "avatarImgIdStr": "109951164981540458"
          },
          "urlInfo": {
            "id": "6A2C396ECE05D4EE713344B7BF240786",
            "url": "http://vodkgeyttp9.vod.126.net/vodkgeyttp8/RJpj35VZ_2516445989_shd.mp4?ts=1627721809&rid=075C5AA92CF77F4909672E580C65832E&rl=3&rs=vquApyDJNmKazDlEQcLlFzTNoaQmwGDL&sign=8b9785c7ab6974d1b990ea96f8d45455&ext=bIfTBSN7onNsmhQlQfxjtzl0Ri8qU6ztTZ3fceDkM4SzFwl7%2BhDApQHnJgMXGvCCO1e2hOj%2BxGHdAnddzunovAfSror7aX2SXFqkX04hCSkUEsYDIc%2BanHPz73N7UxbQ7VsJVVZkga1C2ALJTY%2B1ajeSUEpUPxXG%2BRN3eKjmZVRvNFOdzkdwn8V4HnzYTw68C%2FYdDtqC12KzLkUhbSxYdQdvQ68oiUU5wlW6PEUngO8yh8pq%2Fu0Urj5f4IIpy2nU",
            "size": 108625445,
            "validityTime": 1200,
            "needPay": false,
            "payInfo": null,
            "r": 720
          },
          "videoGroup": [{
              "id": 58100,
              "name": "现场",
              "alg": null
            },
            {
              "id": 1101,
              "name": "舞蹈",
              "alg": null
            },
            {
              "id": 9102,
              "name": "演唱会",
              "alg": null
            },
            {
              "id": 3110,
              "name": "宅舞",
              "alg": null
            },
            {
              "id": 1100,
              "name": "音乐现场",
              "alg": null
            },
            {
              "id": 12100,
              "name": "流行",
              "alg": null
            },
            {
              "id": 3107,
              "name": "混剪",
              "alg": null
            },
            {
              "id": 5100,
              "name": "音乐",
              "alg": null
            },
            {
              "id": 23109,
              "name": "歌曲混剪",
              "alg": null
            },
            {
              "id": 23116,
              "name": "音乐推荐",
              "alg": null
            },
            {
              "id": 16142,
              "name": "日语音乐",
              "alg": null
            }
          ],
          "previewUrl": null,
          "previewDurationms": 0,
          "hasRelatedGameAd": false,
          "markTypes": null,
          "relateSong": [],
          "relatedInfo": null,
          "videoUserLiveInfo": null,
          "vid": "6A2C396ECE05D4EE713344B7BF240786",
          "durationms": 181880,
          "playTime": 1298058,
          "praisedCount": 3730,
          "praised": false,
          "subscribed": false
        }
      },
      {
        "type": 1,
        "displayed": false,
        "alg": "onlineHotGroup",
        "extAlg": null,
        "data": {
          "alg": "onlineHotGroup",
          "scm": "1.music-video-timeline.video_timeline.video.181017.-295043608",
          "threadId": "R_VI_62_7D48305298ECE33896AA886AF2C4777E",
          "coverUrl": "https://p1.music.126.net/zDoq7R_i398DKbr3KXAV7Q==/109951164810761467.jpg",
          "height": 720,
          "width": 1280,
          "title": "【WNS中字】防弹200307BTS日本五期FM大阪 pied piper",
          "description": "【WNS中字】\n防弹少年团200307 TBS BTS\nJAPAN [ MAGIC SHOP ] 五期FM at 大阪\npied piper\n\n撩撩少年团~~~",
          "commentCount": 120,
          "shareCount": 324,
          "resolutions": [{
              "resolution": 240,
              "size": 32102426
            },
            {
              "resolution": 480,
              "size": 54660489
            },
            {
              "resolution": 720,
              "size": 79665504
            }
          ],
          "creator": {
            "defaultAvatar": false,
            "province": 330000,
            "authStatus": 0,
            "followed": false,
            "avatarUrl": "http://p1.music.126.net/NVynzXHARdhfx2kD7F9_Zw==/109951166210769361.jpg",
            "accountStatus": 0,
            "gender": 2,
            "city": 330100,
            "birthday": 922932907521,
            "userId": 1881469094,
            "userType": 207,
            "nickname": "满井之春",
            "signature": "时隐时现。B站同名。阿米，学生党，忙现生，随缘更，有时间就会来云村。\n防弹少年团是我生命中的光。💜\n道之所在，虽千万人吾往矣。",
            "description": "",
            "detailDescription": "",
            "avatarImgId": 109951166210769360,
            "backgroundImgId": 109951165814247650,
            "backgroundUrl": "http://p1.music.126.net/CbJk-0sfXETGbh-7RH8Sgg==/109951165814247645.jpg",
            "authority": 0,
            "mutual": false,
            "expertTags": null,
            "experts": null,
            "djStatus": 10,
            "vipType": 11,
            "remarkName": null,
            "backgroundImgIdStr": "109951165814247645",
            "avatarImgIdStr": "109951166210769361"
          },
          "urlInfo": {
            "id": "7D48305298ECE33896AA886AF2C4777E",
            "url": "http://vodkgeyttp9.vod.126.net/vodkgeyttp8/KuehDtwz_2940186642_shd.mp4?ts=1627721809&rid=075C5AA92CF77F4909672E580C65832E&rl=3&rs=JloWJKzfnGwpFWhCrWPWnaEvCsnGURTx&sign=a27172e0529c21d65028bf87c61b1114&ext=bIfTBSN7onNsmhQlQfxjtzl0Ri8qU6ztTZ3fceDkM4SzFwl7%2BhDApQHnJgMXGvCCO1e2hOj%2BxGHdAnddzunovAfSror7aX2SXFqkX04hCSkUEsYDIc%2BanHPz73N7UxbQ7VsJVVZkga1C2ALJTY%2B1ajeSUEpUPxXG%2BRN3eKjmZVRvNFOdzkdwn8V4HnzYTw68C%2FYdDtqC12KzLkUhbSxYdQdvQ68oiUU5wlW6PEUngO8yh8pq%2Fu0Urj5f4IIpy2nU",
            "size": 79665504,
            "validityTime": 1200,
            "needPay": false,
            "payInfo": null,
            "r": 720
          },
          "videoGroup": [{
              "id": 58100,
              "name": "现场",
              "alg": null
            },
            {
              "id": 57107,
              "name": "韩语现场",
              "alg": null
            },
            {
              "id": 57108,
              "name": "流行现场",
              "alg": null
            },
            {
              "id": 59108,
              "name": "巡演现场",
              "alg": null
            },
            {
              "id": 1100,
              "name": "音乐现场",
              "alg": null
            },
            {
              "id": 5100,
              "name": "音乐",
              "alg": null
            },
            {
              "id": 23116,
              "name": "音乐推荐",
              "alg": null
            }
          ],
          "previewUrl": null,
          "previewDurationms": 0,
          "hasRelatedGameAd": false,
          "markTypes": null,
          "relateSong": [{
            "name": "Pied Piper",
            "id": 506094568,
            "pst": 0,
            "t": 0,
            "ar": [{
              "id": 783124,
              "name": "BTS (防弹少年团)",
              "tns": [],
              "alias": []
            }],
            "alia": [],
            "pop": 100,
            "st": 0,
            "rt": null,
            "fee": 1,
            "v": 93,
            "crbt": null,
            "cf": "",
            "al": {
              "id": 36225110,
              "name": "LOVE YOURSELF 承 'Her'",
              "picUrl": "http://p3.music.126.net/D-wqsmBdtdSRwJ28BH5qiw==/109951163276501729.jpg",
              "tns": [],
              "pic_str": "109951163276501729",
              "pic": 109951163276501730
            },
            "dt": 245473,
            "h": {
              "br": 320000,
              "fid": 0,
              "size": 9829399,
              "vd": -22000
            },
            "m": {
              "br": 192000,
              "fid": 0,
              "size": 5897657,
              "vd": -19400
            },
            "l": {
              "br": 128000,
              "fid": 0,
              "size": 3931786,
              "vd": -17900
            },
            "a": null,
            "cd": "1",
            "no": 5,
            "rtUrl": null,
            "ftype": 0,
            "rtUrls": [],
            "djId": 0,
            "copyright": 2,
            "s_id": 0,
            "rtype": 0,
            "rurl": null,
            "mst": 9,
            "cp": 723010,
            "mv": 0,
            "publishTime": 1505664000007,
            "privilege": {
              "id": 506094568,
              "fee": 1,
              "payed": 0,
              "st": 0,
              "pl": 0,
              "dl": 0,
              "sp": 0,
              "cp": 0,
              "subp": 0,
              "cs": false,
              "maxbr": 320000,
              "fl": 0,
              "toast": false,
              "flag": 68,
              "preSell": false
            }
          }],
          "relatedInfo": null,
          "videoUserLiveInfo": null,
          "vid": "7D48305298ECE33896AA886AF2C4777E",
          "durationms": 242624,
          "playTime": 157716,
          "praisedCount": 3424,
          "praised": false,
          "subscribed": false
        }
      },
      {
        "type": 1,
        "displayed": false,
        "alg": "onlineHotGroup",
        "extAlg": null,
        "data": {
          "alg": "onlineHotGroup",
          "scm": "1.music-video-timeline.video_timeline.video.181017.-295043608",
          "threadId": "R_VI_62_F6B01AB45A0BD207324BE30023CBAAE0",
          "coverUrl": "https://p1.music.126.net/2eLt7-1Va-eZpzQfFw5GIg==/109951163571823754.jpg",
          "height": 720,
          "width": 960,
          "title": "经典情歌《Wonderful Tonight》现场版，一首百听不厌的情歌",
          "description": null,
          "commentCount": 253,
          "shareCount": 2275,
          "resolutions": [{
              "resolution": 240,
              "size": 26866407
            },
            {
              "resolution": 480,
              "size": 41231228
            },
            {
              "resolution": 720,
              "size": 55437725
            }
          ],
          "creator": {
            "defaultAvatar": false,
            "province": 320000,
            "authStatus": 0,
            "followed": false,
            "avatarUrl": "http://p1.music.126.net/eFzWMhJRHobvUeYbA5eOJw==/19043541393240207.jpg",
            "accountStatus": 0,
            "gender": 1,
            "city": 320100,
            "birthday": 604252800000,
            "userId": 16539432,
            "userType": 0,
            "nickname": "摇滚客",
            "signature": "知名音乐新媒体果酱音乐旗下子品牌“摇滚客”，微博关注@摇滚客Rocker 更多精彩视频和音乐福利奉上！",
            "description": "",
            "detailDescription": "",
            "avatarImgId": 19043541393240210,
            "backgroundImgId": 2002210674180201,
            "backgroundUrl": "http://p1.music.126.net/o3G7lWrGBQAvSRt3UuApTw==/2002210674180201.jpg",
            "authority": 0,
            "mutual": false,
            "expertTags": null,
            "experts": {
              "1": "音乐视频达人"
            },
            "djStatus": 10,
            "vipType": 0,
            "remarkName": null,
            "backgroundImgIdStr": "2002210674180201",
            "avatarImgIdStr": "19043541393240207"
          },
          "urlInfo": {
            "id": "F6B01AB45A0BD207324BE30023CBAAE0",
            "url": "http://vodkgeyttp9.vod.126.net/vodkgeyttp8/nFXf6vK9_3140892691_shd.mp4?ts=1627721809&rid=075C5AA92CF77F4909672E580C65832E&rl=3&rs=WoPVTksyYgZTiBXdBSEYWKCRWGXjwELt&sign=720c451be2f2ebb5a98f13c7f1adbff9&ext=bIfTBSN7onNsmhQlQfxjtzl0Ri8qU6ztTZ3fceDkM4SzFwl7%2BhDApQHnJgMXGvCCO1e2hOj%2BxGHdAnddzunovAfSror7aX2SXFqkX04hCSkUEsYDIc%2BanHPz73N7UxbQ7VsJVVZkga1C2ALJTY%2B1ajeSUEpUPxXG%2BRN3eKjmZVRvNFOdzkdwn8V4HnzYTw68C%2FYdDtqC12KzLkUhbSxYdQdvQ68oiUU5wlW6PEUngO8yh8pq%2Fu0Urj5f4IIpy2nU",
            "size": 55437725,
            "validityTime": 1200,
            "needPay": false,
            "payInfo": null,
            "r": 720
          },
          "videoGroup": [{
              "id": 58100,
              "name": "现场",
              "alg": null
            },
            {
              "id": 1100,
              "name": "音乐现场",
              "alg": null
            },
            {
              "id": 5100,
              "name": "音乐",
              "alg": null
            },
            {
              "id": 25137,
              "name": "音乐资讯",
              "alg": null
            }
          ],
          "previewUrl": null,
          "previewDurationms": 0,
          "hasRelatedGameAd": false,
          "markTypes": [
            109
          ],
          "relateSong": [],
          "relatedInfo": null,
          "videoUserLiveInfo": null,
          "vid": "F6B01AB45A0BD207324BE30023CBAAE0",
          "durationms": 370000,
          "playTime": 505451,
          "praisedCount": 2605,
          "praised": false,
          "subscribed": false
        }
      },
      {
        "type": 1,
        "displayed": false,
        "alg": "onlineHotGroup",
        "extAlg": null,
        "data": {
          "alg": "onlineHotGroup",
          "scm": "1.music-video-timeline.video_timeline.video.181017.-295043608",
          "threadId": "R_VI_62_31CAADFADE3C69B86438E1939D21C9DB",
          "coverUrl": "https://p1.music.126.net/TkMZOq3BuIDSUtFpn1sxOg==/109951165071106107.jpg",
          "height": 360,
          "width": 640,
          "title": "谢霆锋王俊凯乐队无限公司《谢谢你的爱》",
          "description": "迷妹尖叫！！！🦀🦀🦀",
          "commentCount": 13,
          "shareCount": 19,
          "resolutions": [{
              "resolution": 1080,
              "size": 158301361
            },
            {
              "resolution": 720,
              "size": 95373462
            },
            {
              "resolution": 480,
              "size": 63735300
            },
            {
              "resolution": 240,
              "size": 36345561
            }
          ],
          "creator": {
            "defaultAvatar": false,
            "province": 370000,
            "authStatus": 0,
            "followed": false,
            "avatarUrl": "http://p1.music.126.net/_Eee5T8n-LTphzWl9RCPpA==/109951165771026248.jpg",
            "accountStatus": 0,
            "gender": 2,
            "city": 370800,
            "birthday": 767894400000,
            "userId": 100570421,
            "userType": 204,
            "nickname": "长安第一梦公子",
            "signature": "我爱古风，即使孤芳自赏。b站，同ID",
            "description": "",
            "detailDescription": "",
            "avatarImgId": 109951165771026240,
            "backgroundImgId": 109951165603827460,
            "backgroundUrl": "http://p1.music.126.net/YhDh_BZPKwZEqBuEjvw2Sw==/109951165603827464.jpg",
            "authority": 0,
            "mutual": false,
            "expertTags": null,
            "experts": {
              "1": "音乐视频达人"
            },
            "djStatus": 10,
            "vipType": 11,
            "remarkName": null,
            "backgroundImgIdStr": "109951165603827464",
            "avatarImgIdStr": "109951165771026248"
          },
          "urlInfo": {
            "id": "31CAADFADE3C69B86438E1939D21C9DB",
            "url": "http://vodkgeyttp9.vod.126.net/vodkgeyttp8/T7hyHrNA_3034029820_uhd.mp4?ts=1627721809&rid=075C5AA92CF77F4909672E580C65832E&rl=3&rs=FDoqssjAfVyyMSjSdDbAwCJGMgmxhdbJ&sign=22a54131bc2df475baf2c5ba776ac4de&ext=bIfTBSN7onNsmhQlQfxjtzl0Ri8qU6ztTZ3fceDkM4SzFwl7%2BhDApQHnJgMXGvCCO1e2hOj%2BxGHdAnddzunovAfSror7aX2SXFqkX04hCSkUEsYDIc%2BanHPz73N7UxbQ7VsJVVZkga1C2ALJTY%2B1ajeSUEpUPxXG%2BRN3eKjmZVRvNFOdzkdwn8V4HnzYTw68C%2FYdDtqC12KzLkUhbSxYdQdvQ68oiUU5wlW6PEUngO8yh8pq%2Fu0Urj5f4IIpy2nU",
            "size": 158301361,
            "validityTime": 1200,
            "needPay": false,
            "payInfo": null,
            "r": 1080
          },
          "videoGroup": [{
              "id": 58100,
              "name": "现场",
              "alg": null
            },
            {
              "id": 59101,
              "name": "华语现场",
              "alg": null
            },
            {
              "id": 57108,
              "name": "流行现场",
              "alg": null
            },
            {
              "id": 59108,
              "name": "巡演现场",
              "alg": null
            },
            {
              "id": 11137,
              "name": "TFBOYS",
              "alg": null
            },
            {
              "id": 1100,
              "name": "音乐现场",
              "alg": null
            },
            {
              "id": 5100,
              "name": "音乐",
              "alg": null
            },
            {
              "id": 25108,
              "name": "王俊凯",
              "alg": null
            }
          ],
          "previewUrl": null,
          "previewDurationms": 0,
          "hasRelatedGameAd": false,
          "markTypes": null,
          "relateSong": [],
          "relatedInfo": null,
          "videoUserLiveInfo": null,
          "vid": "31CAADFADE3C69B86438E1939D21C9DB",
          "durationms": 200596,
          "playTime": 35779,
          "praisedCount": 258,
          "praised": false,
          "subscribed": false
        }
      },
      {
        "type": 1,
        "displayed": false,
        "alg": "onlineHotGroup",
        "extAlg": null,
        "data": {
          "alg": "onlineHotGroup",
          "scm": "1.music-video-timeline.video_timeline.video.181017.-295043608",
          "threadId": "R_VI_62_05FFB1E9F2798ED92B177936822E7386",
          "coverUrl": "https://p1.music.126.net/J7ZBVzR7hIgzjsM1C0YxSg==/109951164890644091.jpg",
          "height": 1080,
          "width": 1920,
          "title": "ZARD•坂井泉水－運命のルーレット廻して",
          "description": "ZARD•坂井泉水\n運命のルーレット廻して(TV on-air ver)（转动命运之轮）\n",
          "commentCount": 30,
          "shareCount": 91,
          "resolutions": [{
              "resolution": 240,
              "size": 27041299
            },
            {
              "resolution": 480,
              "size": 47826259
            },
            {
              "resolution": 720,
              "size": 70914770
            },
            {
              "resolution": 1080,
              "size": 120533937
            }
          ],
          "creator": {
            "defaultAvatar": false,
            "province": 620000,
            "authStatus": 0,
            "followed": false,
            "avatarUrl": "http://p1.music.126.net/UQQnoTshADtqLL8axdLHYQ==/109951163440122759.jpg",
            "accountStatus": 0,
            "gender": 0,
            "city": 620100,
            "birthday": 346521600000,
            "userId": 253168814,
            "userType": 0,
            "nickname": "烈焰飞雪1225",
            "signature": "山口百惠 中岛美雪永远的女神\n各类经典歌曲收藏",
            "description": "",
            "detailDescription": "",
            "avatarImgId": 109951163440122750,
            "backgroundImgId": 2002210674180200,
            "backgroundUrl": "http://p1.music.126.net/45Nu4EqvFqK_kQj6BkPwcw==/2002210674180200.jpg",
            "authority": 0,
            "mutual": false,
            "expertTags": null,
            "experts": null,
            "djStatus": 0,
            "vipType": 0,
            "remarkName": null,
            "backgroundImgIdStr": "2002210674180200",
            "avatarImgIdStr": "109951163440122759"
          },
          "urlInfo": {
            "id": "05FFB1E9F2798ED92B177936822E7386",
            "url": "http://vodkgeyttp9.vod.126.net/vodkgeyttp8/wZ3eqJQM_2957127953_uhd.mp4?ts=1627721809&rid=075C5AA92CF77F4909672E580C65832E&rl=3&rs=aHoSOLRhKCPAhHfuSxlhkeTTGFGlMjwO&sign=01628f14267d1f7c384fe1f7d298985b&ext=bIfTBSN7onNsmhQlQfxjtzl0Ri8qU6ztTZ3fceDkM4SzFwl7%2BhDApQHnJgMXGvCCO1e2hOj%2BxGHdAnddzunovAfSror7aX2SXFqkX04hCSkUEsYDIc%2BanHPz73N7UxbQ7VsJVVZkga1C2ALJTY%2B1ajeSUEpUPxXG%2BRN3eKjmZVRvNFOdzkdwn8V4HnzYTw68C%2FYdDtqC12KzLkUhbSxYdQdvQ68oiUU5wlW6PEUngO8yh8pq%2Fu0Urj5f4IIpy2nU",
            "size": 120533937,
            "validityTime": 1200,
            "needPay": false,
            "payInfo": null,
            "r": 1080
          },
          "videoGroup": [{
              "id": 58100,
              "name": "现场",
              "alg": null
            },
            {
              "id": 60101,
              "name": "日语现场",
              "alg": null
            },
            {
              "id": 57108,
              "name": "流行现场",
              "alg": null
            },
            {
              "id": 59108,
              "name": "巡演现场",
              "alg": null
            },
            {
              "id": 1100,
              "name": "音乐现场",
              "alg": null
            },
            {
              "id": 5100,
              "name": "音乐",
              "alg": null
            }
          ],
          "previewUrl": null,
          "previewDurationms": 0,
          "hasRelatedGameAd": false,
          "markTypes": null,
          "relateSong": [],
          "relatedInfo": null,
          "videoUserLiveInfo": null,
          "vid": "05FFB1E9F2798ED92B177936822E7386",
          "durationms": 288508,
          "playTime": 54480,
          "praisedCount": 446,
          "praised": false,
          "subscribed": false
        }
      },
      {
        "type": 1,
        "displayed": false,
        "alg": "onlineHotGroup",
        "extAlg": null,
        "data": {
          "alg": "onlineHotGroup",
          "scm": "1.music-video-timeline.video_timeline.video.181017.-295043608",
          "threadId": "R_VI_62_097E5ACF942A93DB6788B205419066B4",
          "coverUrl": "https://p1.music.126.net/04NoDqvtZYkIUMSG-ZrSpw==/109951163969781699.jpg",
          "height": 720,
          "width": 1280,
          "title": "G.E.M.邓紫棋实力改编《夜空中最亮的星》，震撼全场！",
          "description": "#G.E.M.邓紫棋#\n夜空中最亮的星✨\n请照亮我前行💫",
          "commentCount": 117,
          "shareCount": 508,
          "resolutions": [{
              "resolution": 240,
              "size": 31001867
            },
            {
              "resolution": 480,
              "size": 51113354
            },
            {
              "resolution": 720,
              "size": 86591389
            }
          ],
          "creator": {
            "defaultAvatar": false,
            "province": 210000,
            "authStatus": 0,
            "followed": false,
            "avatarUrl": "http://p1.music.126.net/imzQB_QBnvYIjoQ63WAu0g==/109951166179438813.jpg",
            "accountStatus": 0,
            "gender": 2,
            "city": 210200,
            "birthday": 873734400000,
            "userId": 596235479,
            "userType": 207,
            "nickname": "飘向北方的GEM",
            "signature": "随缘更新🈺",
            "description": "",
            "detailDescription": "",
            "avatarImgId": 109951166179438820,
            "backgroundImgId": 109951166217623620,
            "backgroundUrl": "http://p1.music.126.net/6ETCQkOgeWwXeRtRZdFb0Q==/109951166217623622.jpg",
            "authority": 0,
            "mutual": false,
            "expertTags": null,
            "experts": {
              "1": "音乐视频达人",
              "2": "音乐图文达人"
            },
            "djStatus": 10,
            "vipType": 0,
            "remarkName": null,
            "backgroundImgIdStr": "109951166217623622",
            "avatarImgIdStr": "109951166179438813"
          },
          "urlInfo": {
            "id": "097E5ACF942A93DB6788B205419066B4",
            "url": "http://vodkgeyttp9.vod.126.net/vodkgeyttp8/vTkMqmZI_2417843649_shd.mp4?ts=1627721809&rid=075C5AA92CF77F4909672E580C65832E&rl=3&rs=JWjiICLLpcSYdCqNeAvYqfvboCILZcxm&sign=b347171fdd18beb62b89fe76fd7b7fa5&ext=bIfTBSN7onNsmhQlQfxjtzl0Ri8qU6ztTZ3fceDkM4SzFwl7%2BhDApQHnJgMXGvCCO1e2hOj%2BxGHdAnddzunovAfSror7aX2SXFqkX04hCSkUEsYDIc%2BanHPz73N7UxbQ7VsJVVZkga1C2ALJTY%2B1ajeSUEpUPxXG%2BRN3eKjmZVRvNFOdzkdwn8V4HnzYTw68C%2FYdDtqC12KzLkUhbSxYdQdvQ68oiUU5wlW6PEUngO8yh8pq%2Fu0Urj5f4IIpy2nU",
            "size": 86591389,
            "validityTime": 1200,
            "needPay": false,
            "payInfo": null,
            "r": 720
          },
          "videoGroup": [{
              "id": 58100,
              "name": "现场",
              "alg": null
            },
            {
              "id": 59101,
              "name": "华语现场",
              "alg": null
            },
            {
              "id": 57108,
              "name": "流行现场",
              "alg": null
            },
            {
              "id": 59108,
              "name": "巡演现场",
              "alg": null
            },
            {
              "id": 1100,
              "name": "音乐现场",
              "alg": null
            },
            {
              "id": 5100,
              "name": "音乐",
              "alg": null
            },
            {
              "id": 16233,
              "name": "G.E.M.邓紫棋",
              "alg": null
            }
          ],
          "previewUrl": null,
          "previewDurationms": 0,
          "hasRelatedGameAd": false,
          "markTypes": null,
          "relateSong": [{
            "name": "夜空中最亮的星",
            "id": 25706282,
            "pst": 0,
            "t": 0,
            "ar": [{
              "id": 12977,
              "name": "逃跑计划",
              "tns": [],
              "alias": []
            }],
            "alia": [],
            "pop": 100,
            "st": 0,
            "rt": "600902000009535440",
            "fee": 8,
            "v": 125,
            "crbt": null,
            "cf": "",
            "al": {
              "id": 2285010,
              "name": "世界",
              "picUrl": "http://p4.music.126.net/Eef2K2KV9dT3XUA6_Ve-Rw==/109951165543196748.jpg",
              "tns": [],
              "pic_str": "109951165543196748",
              "pic": 109951165543196750
            },
            "dt": 252000,
            "h": {
              "br": 320000,
              "fid": 0,
              "size": 10091667,
              "vd": -3700
            },
            "m": {
              "br": 192000,
              "fid": 0,
              "size": 6055017,
              "vd": -1200
            },
            "l": {
              "br": 128000,
              "fid": 0,
              "size": 4036692,
              "vd": -2
            },
            "a": null,
            "cd": "1",
            "no": 7,
            "rtUrl": null,
            "ftype": 0,
            "rtUrls": [],
            "djId": 0,
            "copyright": 1,
            "s_id": 0,
            "rtype": 0,
            "rurl": null,
            "mst": 9,
            "cp": 22036,
            "mv": 382555,
            "publishTime": 1325347200007,
            "privilege": {
              "id": 25706282,
              "fee": 8,
              "payed": 0,
              "st": 0,
              "pl": 128000,
              "dl": 0,
              "sp": 7,
              "cp": 1,
              "subp": 1,
              "cs": false,
              "maxbr": 999000,
              "fl": 128000,
              "toast": false,
              "flag": 4,
              "preSell": false
            }
          }],
          "relatedInfo": null,
          "videoUserLiveInfo": null,
          "vid": "097E5ACF942A93DB6788B205419066B4",
          "durationms": 246224,
          "playTime": 474855,
          "praisedCount": 3239,
          "praised": false,
          "subscribed": false
        }
      },
      {
        "type": 1,
        "displayed": false,
        "alg": "onlineHotGroup",
        "extAlg": null,
        "data": {
          "alg": "onlineHotGroup",
          "scm": "1.music-video-timeline.video_timeline.video.181017.-295043608",
          "threadId": "R_VI_62_F517F05037CE51FADEC92D392B99960F",
          "coverUrl": "https://p1.music.126.net/VRjSPf-20nV3OOsrAKShxg==/109951164587718190.jpg",
          "height": 720,
          "width": 1280,
          "title": "【LongRoad】20191222 易烊千玺演唱会《舒适圈》",
          "description": "难忘今宵之《舒适圈》",
          "commentCount": 87,
          "shareCount": 643,
          "resolutions": [{
              "resolution": 240,
              "size": 58526574
            },
            {
              "resolution": 480,
              "size": 97727795
            },
            {
              "resolution": 720,
              "size": 145980761
            }
          ],
          "creator": {
            "defaultAvatar": false,
            "province": 110000,
            "authStatus": 0,
            "followed": false,
            "avatarUrl": "http://p1.music.126.net/bKcUJb5nAjiHGVJykzVP8g==/109951163695411327.jpg",
            "accountStatus": 0,
            "gender": 1,
            "city": 110105,
            "birthday": -2209017600000,
            "userId": 504642785,
            "userType": 0,
            "nickname": "LongRoad_易烊千玺个站",
            "signature": "长路漫漫 无悔相伴",
            "description": "",
            "detailDescription": "",
            "avatarImgId": 109951163695411330,
            "backgroundImgId": 109951162868128400,
            "backgroundUrl": "http://p1.music.126.net/2zSNIqTcpHL2jIvU6hG0EA==/109951162868128395.jpg",
            "authority": 0,
            "mutual": false,
            "expertTags": null,
            "experts": null,
            "djStatus": 0,
            "vipType": 0,
            "remarkName": null,
            "backgroundImgIdStr": "109951162868128395",
            "avatarImgIdStr": "109951163695411327"
          },
          "urlInfo": {
            "id": "F517F05037CE51FADEC92D392B99960F",
            "url": "http://vodkgeyttp9.vod.126.net/vodkgeyttp8/ySITH6ys_2860697661_shd.mp4?ts=1627721809&rid=075C5AA92CF77F4909672E580C65832E&rl=3&rs=ORCQwQYuxkJhHzfxPmSSlOchTFfBfefW&sign=06b224b94dd3b5cdd8a0771c96ebef93&ext=bIfTBSN7onNsmhQlQfxjtzl0Ri8qU6ztTZ3fceDkM4SzFwl7%2BhDApQHnJgMXGvCCO1e2hOj%2BxGHdAnddzunovAfSror7aX2SXFqkX04hCSkUEsYDIc%2BanHPz73N7UxbQ7VsJVVZkga1C2ALJTY%2B1ajeSUEpUPxXG%2BRN3eKjmZVRvNFOdzkdwn8V4HnzYTw68C%2FYdDtqC12KzLkUhbSxYdQdvQ68oiUU5wlW6PEUngO8yh8pq%2Fu0Urj5f4IIpy2nU",
            "size": 145980761,
            "validityTime": 1200,
            "needPay": false,
            "payInfo": null,
            "r": 720
          },
          "videoGroup": [{
              "id": 58100,
              "name": "现场",
              "alg": null
            },
            {
              "id": 11137,
              "name": "TFBOYS",
              "alg": null
            },
            {
              "id": 1100,
              "name": "音乐现场",
              "alg": null
            },
            {
              "id": 5100,
              "name": "音乐",
              "alg": null
            },
            {
              "id": 25124,
              "name": "易烊千玺",
              "alg": null
            }
          ],
          "previewUrl": null,
          "previewDurationms": 0,
          "hasRelatedGameAd": false,
          "markTypes": null,
          "relateSong": [],
          "relatedInfo": null,
          "videoUserLiveInfo": null,
          "vid": "F517F05037CE51FADEC92D392B99960F",
          "durationms": 290200,
          "playTime": 139799,
          "praisedCount": 2670,
          "praised": false,
          "subscribed": false
        }
      }
    ]

    let navItemList = this.data.navItemList;
    //将视频最新的数据更新到原有视频列表数据中
    navItemList.push(...newVideoList);
    this.setData({
      navItemList
    })
  },

  // 用户点击右上角进行分享
  onShareAppMessage: function({ from, target }) {
    console.log(from); // 可以判断通过button还是menu分享的
    console.log(target);
    // 可以设置分享的页面内容
    if (from === 'button') {
      return {
        title: target.dataset.data.title,
        page: '/pages/video/video',
        imageUrl: target.dataset.data.coverUrl
      }
    } else {
      return {
        title: '来自云歌的分享~',
        page: '/pages/video/video',
      }
    }
  }
})